package sdk.webview.fmc.com.fmcsdk.check.adapter;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Objects;

import sdk.webview.fmc.com.fmcsdk.R;
import sdk.webview.fmc.com.fmcsdk.check.bean.WorkStatusBean;
import sdk.webview.fmc.com.fmcsdk.view.RoundImageView;

public class SelectPeopleAdapter extends BaseQuickAdapter<WorkStatusBean.ContactPersonBean, BaseViewHolder> {
    public SelectPeopleAdapter(@Nullable List<WorkStatusBean.ContactPersonBean> data) {
        super(R.layout.item_peo_select, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, WorkStatusBean.ContactPersonBean item) {
        holder.setText(R.id.tv_name, item.getUserName());
        holder.setGone(R.id.tv_is_group, !item.getIsAdmin().equals(0));
        holder.setVisible(R.id.tv_is_busy, Objects.equals(item.getStatus(), "1"));
        RoundImageView iv_photo = holder.getView(R.id.iv_photo);
        Glide.with(mContext).load(item.getUrl()).error(R.mipmap.icon_default).into(iv_photo);
        if (item.isSelect){
            holder.setImageResource(R.id.iv_sel, R.mipmap.icon_check_red);
        }else {
            holder.setImageResource(R.id.iv_sel, R.mipmap.icon_select_no);
        }
        holder.setGone(R.id.tv_desc, null != item.getWorkType() && !item.getWorkType().isEmpty());
        holder.setText(R.id.tv_desc, "正在处理:"+item.getWorkType());
        holder.setGone(R.id.view_line, holder.getAdapterPosition() != getData().size() - 1);
    }

}
